
/* 

Paper: Gentrification and pioneer businesses 
Authors: Behrens, Boulam, Martin, Mayneris 

Name dofile: identify_pioneers_logit.do  
Version: 11 nov. 2021 

Output: dataset pioneers_final_logit.dta with the list of pioneer sectors  obtained using a logit rather than negative binomial

Inputs:

 - pioneer_gentri90_only`n'_dum_`v'_1990 with n in {pc, sh_edu, gentri} and v in {250, 500, cont} [produced in compute_elasticity_logit.do] [publicly available]

*/ 


foreach n in "250" "500" "cont"{
	foreach v in "pc" "sh_edu"{
	use pioneer_gentri90_only`n'_dum_`v'_1990.dta,clear
	
	// we generate dummies for significance of coefficients
	g siginit`n'=abs(coef_`v'_gr_poor_init`n'/se_`v'_gr_poor_init`n')>2.576&coef_`v'_gr_poor_init`n'!=.
	g siginit_pcinc`n'=abs(coef_poor_init`n'/ se_poor_init`n')>2.576&coef_poor_init`n'!=.
	
	// we create dummies for pioneers 
	gen pioneer_`n'_`v'_high= (coef_poor_init`n'<0&siginit_pcinc`n'==1&coef_`v'_gr_poor_init`n'>0&siginit`n'==1)
	
	rename nb_block_active nb_block_active`v'
	save pioneers`n'_dum_`v'.dta, replace  
		}
	}
	
foreach n in "250" "500" "cont"{
	foreach v in "gentri"{
	use pioneer_gentri90_only`n'_dum_`v'_1990.dta, clear
	
	// we generate dummies for significance of coefficients
	g siginit`n'=abs(coef_`v'_init`n'/se_`v'_init`n')>2.576&coef_`v'_init`n'!=.
	g siginit_pcinc`n'=abs(coef_poor_init`n'/ se_poor_init`n')>2.576&coef_poor_init`n'!=.
	
	// we create dummies for pioneers 
	gen pioneer_`n'_`v'_high= (coef_poor_init`n'<0&siginit_pcinc`n'==1&coef_`v'_init`n'>0&siginit`n'==1)
	save pioneers`n'_dum_`v'.dta, replace  
		}
	}

	// we define as pioneer sectors that appear as such for at least 2 out of the 3 estimations
	use pioneers250_dum_gentri.dta, clear
	merge 1:1 naics using pioneers500_dum_gentri.dta
	drop _m
	merge 1:1 naics using pioneerscont_dum_gentri.dta
	drop _m
	foreach n in "250" "500" "cont"{
	foreach v in "pc" "sh_edu"{
	merge 1:1 naics using pioneers`n'_dum_`v'.dta
	drop _m
		}
	}
	
		
	gen var_pioneer_high=pioneer_250_pc_high+pioneer_500_pc_high+pioneer_cont_pc_high+pioneer_250_sh_edu_high+pioneer_500_sh_edu_high+pioneer_cont_sh_edu_high+pioneer_250_gentri_high+pioneer_500_gentri_high+pioneer_cont_gentri_high

	gen pioneer_high_dum= (var_pioneer_high>5&var_pioneer_high!=.)
	keep naics* pioneer_high_dum 
	label var pioneer_high_dum "Dummy is 1 if the sector is pioneers (logit)"
	save pioneers_final_dum.dta, replace
	
	
	